<template>
    <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="account" label="account" width="180" />
    <el-table-column prop="createTime" label="createTime" width="180" />
    <el-table-column prop="level" label="level" />
  </el-table>

  <div class="demo-pagination-block">
    <div class="demonstration">All combined</div>
    <el-pagination
      v-model:current-page="currentPage4"
      v-model:page-size="pageSize4"
      :page-sizes="[10, 20, 30, 400]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup>

import { ref } from "vue";

const data = Array.from(Array(114), (v,i) =>{
    return {
        account: 'uaa'+ (i+1),
        createTime: new Date(Date.now() + Math.ceil(Math.random()*1000)),
        level: Math.ceil(Math.random()*10)
    }
})

console.log(data);

const tableData = ref([])
const currentPage = ref(1)
const pageSize = ref(5)
const total = ref(0)
const currentPage4 = ref(4)
const pageSize4 = ref(100)

const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
  getData(currentPage.value,val)
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
  getData(val,pageSize.value)
}

const getData=(page,pageSize)=>{
    tableData.value = data.slice((page - 1)*pageSize,page*pageSize)
    total.value = data.length
}
getData(1,pageSize.value)
</script>